package utility;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Vector;

public class DayMonthYear {
	
	/**
	 * @author Tidus
	 * @param monthYear(mm/yyyy)
	 * @return String[] listDayofMonth
	 */
	public static String[] listDaysofMonth(String monthYear){
		Vector<String> list = StringUtil.subStr(monthYear, "/");
		int month = Integer.parseInt(list.get(0));
		int year = Integer.parseInt(list.get(1));
		
		Calendar cal = new GregorianCalendar(year, month-1, 1);

		// Get the number of days in that month
		int totalDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
		String[] days = new String[totalDay];
		for(int i = 0; i <totalDay; i++){
			if(i<9){
				days[i] = "0" + Integer.toString(i+1) + "/" + monthYear;
			}else{
				days[i] = Integer.toString(i+1) + "/" + monthYear;
			}
		}
		return days;
	}
	
	/**
	 * @author Tidus
	 * @param month int
	 * @param year int
	 * @return String monthYear [mm/yyyy]
	 */
	public static String monthYear(int month, int year){
		String monthYear;
		String m;
		if(month <10){
			m = "0"+Integer.toString(month);
		}else{
			m = Integer.toString(month);
		}
		String y = Integer.toString(year);
		monthYear = m+"/"+y;
		return monthYear;
	}
	
	/**
	 * @author Tidus
	 * @param quater int
	 * @param year int
	 * @return String quaterYear [mm/yyyy]
	 */
	public static String quaterYear(int quater, int year){
		String quaterYear;
		String q = "";
		switch (quater) {
			case 0: q ="I";			
					break;
			case 1: q ="II";			
					break;
			case 2: q ="III";			
					break;
			case 3: q ="IV";			
					break;
		}
		String y = Integer.toString(year);
		quaterYear = q+"/"+y;
		return quaterYear;
	}
	
}
